from django.db import models

from apps.users.models import UserProfile
from apps.plan.models import Plan
# Create your models here.


class Report(models.Model):
    """
    测试报告
    """
    name = models.CharField(max_length=30, verbose_name=u'报告名称')
    total = models.IntegerField(default=0, verbose_name='用例总数')
    success = models.IntegerField(default=0, verbose_name='测试通过数量')
    fail = models.IntegerField(default=0, verbose_name='失败数量')
    plan = models.ForeignKey(Plan, on_delete=models.CASCADE, blank=True, verbose_name='计划id')
    report_path = models.CharField(max_length=50, default='',  verbose_name='测试报告')
    creator = models.ForeignKey(UserProfile, on_delete=models.CASCADE, blank=True, null=True, verbose_name='创建人')
    add_time = models.DateTimeField(auto_now_add=True, verbose_name=u'创建时间')
    edit_time = models.DateTimeField(auto_now=True, verbose_name=u'修改时间')

    class Meta:
        db_table = 't_report'
        verbose_name = '报告'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
